build_exe(){
     cd build-ut
     cmake -DBUILD_UT=ON ..
     make -j16
}

create_coverage_report(){
     workdir=$(cd $(dirname $0)/build-ut; pwd)
     PROJECT_NAME=UtCore #可执行程序的文件名
     PROJECT_REALNAME=MkCore  #项目名称

     echo " ===================CREAT LCOV REPROT==================== "
     lcov --directory ./Ut/CMakeFiles/${PROJECT_REALNAME}.dir --zerocounters
     ./Ut/${PROJECT_NAME} --gtest_output=xml:./report/report_mknetwork.xml
     lcov --directory . --capture --output-file ./html/${PROJECT_REALNAME}_Coverage.info
     echo " =================== do filter begin ==================== "
     lcov --remove ./html/${PROJECT_REALNAME}_Coverage.info  '${PROJECT_NAME}_autogen/*/*' 'googletest/*/*' '*/usr/include/*' '*/Ut/*' '/usr/local/*'  -o ./html/${PROJECT_REALNAME}_Coverage_fileter.info
     echo " =================== do filter end ==================== "

     genhtml -o ./html ./html/${PROJECT_REALNAME}_Coverage_fileter.info
     echo " -- Coverage files have been output to ${CMAKE_BINARY_DIR}/html"
     mv ./html/index.html ./html/cov_${PROJECT_REALNAME}.html
     mv asan.log* asan_${PROJECT_REALNAME}.log
	 cat asan_${PROJECT_REALNAME}.log
}

rm -rf build-ut/asan_MkCore.log
build_exe
create_coverage_report
exit 0

